import Mock from 'mockjs'
import {param2Obj} from '@/utils'

const List = [],
  betRechargeList = [],
  platformBalance = []
const count = 50

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment(1, 100)',
    time: +Mock.Random.date('T'),
    activity: '@int(100,1000)',
    highest: '@int(100,1000)',
    register: '@int(100,1000)',
    recharge: '@int(100,1000)',
    bet: '@int(100,1000)',
    withdraw: '@int(100,1000)',
  }))
  betRechargeList.push(Mock.mock({
    id: '@increment(1, 100)',
    time: +Mock.Random.date('T'),
    account: '@first',
    recharge: '@int(100,1000)',
    bet: '@int(100,1000)',
    ag: '@int(100,1000)',
    pt: '@int(100,1000)',
    center: '@int(100,1000)',
    total: '@int(100,1000)',
    profit: '@int(100,1000)',
    'source|1': _.map(consts.DEVICE_TYPE, 'value')
  }))


}

export default {
  [api.STATISTICAL_MEMBERS]: config => {
    const {page = 1, limit = 20} = param2Obj(config.body)

    let mockList = List.filter(item => {
      // if (importance && item.importance !== +importance) return false;
      if (status && Number(item.status) !== Number(status)) return false;
      // if (title && item.title.indexOf(title) < 0) return false;
      return true;
    })

    // if (sort === '-id') {
    //   mockList = mockList.reverse();
    // }

    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));

    return {
      data: {
        total: mockList.length,
        list: pageList
      },
      code: 1,
    };
  },
  [api.STATISTICAL_BET_RECHARGE]: config => {
    const {page = 1, limit = 20} = param2Obj(config.body)

    let mockList = betRechargeList.filter(item => {
      // if (importance && item.importance !== +importance) return false;
      if (status && Number(item.status) !== Number(status)) return false;
      // if (title && item.title.indexOf(title) < 0) return false;
      return true;
    })

    // if (sort === '-id') {
    //   mockList = mockList.reverse();
    // }

    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));

    return {
      data: {
        total: mockList.length,
        list: pageList
      },
      code: 1,
    };
  },
  [api.STATISTICAL_BALANCE]: config => {
    const {page = 1, limit = 20} = param2Obj(config.body)

    let mockList = betRechargeList.filter(item => {
      // if (importance && item.importance !== +importance) return false;
      if (status && Number(item.status) !== Number(status)) return false;
      // if (title && item.title.indexOf(title) < 0) return false;
      return true;
    })

    // if (sort === '-id') {
    //   mockList = mockList.reverse();
    // }

    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));

    return {
      data: {
        total: mockList.length,
        list: pageList
      },
      code: 1,
    };
  },
  [api.STATISTICAL_BALANCE_TODAY]: config => {
    const {page = 1, limit = 20} = param2Obj(config.body)

    let mockList = betRechargeList.filter(item => {
      // if (importance && item.importance !== +importance) return false;
      if (status && Number(item.status) !== Number(status)) return false;
      // if (title && item.title.indexOf(title) < 0) return false;
      return true;
    })

    // if (sort === '-id') {
    //   mockList = mockList.reverse();
    // }

    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));

    return {
      data: {
        total: mockList.length,
        list: pageList
      },
      code: 1,
    };
  },
  [api.STATISTICAL_HOURS_RECHARGE]: config => {

    const hoursRecharge = [
      {
        props: 'account',
        label: '主账户余额',
        time: +Mock.Random.date('T'),
        value: 1000,
        time1: 1111,
        time2: 2221,
        time3: 1111,
      },
      {
        props: 'account',
        label: '主账户余额',
        time: +Mock.Random.date('T'),
        value: 1000,
        time1: 1111,
        time2: 2221,
        time3: 1111,
      },
    ]

    return {
      data: {
        list: hoursRecharge
      },
      code: 1,
    };
  },
}
